import request from './request';

const http = {
  get(url, params) {
    const config = {
      method: 'get',
      url: url
    };
    if (params) config.url = params;
    return request(config);
  },

  postContentType(url, params) {
    const config = {
      method: 'post',
      url: url
    };
    if (params) config.data = params;
    return request(config);
  },

  post(url, params) {
    const config = {
      method: 'post',
      url: url
    };
    config.headers = {
      'Content-Type': 'application/json'
    };
    if (params) config.data = params;
    return request(config);
  },

  upload(url, params) {
    const config = {
      method: 'post',
      url: url
    };
    if (params) {
      config.data = params;
      config.headers = {
        'Content-Type': 'multipart/form-data' //配置请求头
      };
    }
    return request(config);
  }
  
};

export default http;
